//
//  NewFroendsViewController.m
//  AAIM
//
//  Created by awh on 2019/12/8.
//  Copyright © 2019年 AAIM. All rights reserved.
//

#import "NewFroendsViewController.h"
#import "FriendRequestsViewController.h"
#import "FirendsTableViewCell.h"
#import "ContactRequestLogic.h"
#import "NewFriendModel.h"
#import "FriendsInfoViewController.h"
#import "BTMessageModel.h"
@interface NewFroendsViewController ()
<UITableViewDelegate,UITableViewDataSource,FirendsTableViewCellDelegate>
@property (nonatomic,strong)UITableView * friendsTable;//搜索历史
@property (nonatomic,strong)NSMutableArray*searchResultsArray;
@property (nonatomic,strong)MJTableViewNullDataView *nullDataView;
@property(nonatomic,strong)CustomAlertView * sendAddFriendAlert;
@property (nonatomic,copy)NSString * newsType;//消息类型，0验证消息，1通讯录好友

@end

@implementation NewFroendsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gk_navTitle=@"新好友";
    [self setui];
    [CacheTool removeUserDefaults:[NSString stringWithFormat:@"system_tabbarNum_%@",[LoginManager shareLoginManager].userModel.fuuid]];
    if (self.friendVCBlock) {
        self.friendVCBlock(@"refreshRedDot");
    }
    [[NSNotificationCenter defaultCenter]postNotificationName:kMessageSystemRemoveRedDot object:nil];
    
  
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated{
    [self loadData];
}
- (NSArray *)dictionaryWithJsonString:(NSString *)jsonString
{
    if (jsonString == nil) {
        return nil;
    }
    
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    //    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
    NSArray * ary = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
    if(err)
    {
        //        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    
    
    
    //    for (NSDictionary * provDic in ary) {
    //        if (provDic[@"name"]) {
    //            [self.provinces addObject:@{provDic[@"code"]:provDic[@"name"]}];
    //
    //        }
    //        for (NSDictionary * cityD in provDic[@"citys"]) {
    //            [self.citysArr addObject:@{cityD[@"code"]:cityD[@"name"]}];
    //        }
    //    }
    
    return ary;
}


-(void)loadData
{
    NSMutableArray * ValidationFriends=[NSMutableArray new];
    NSMutableArray * localFriends=[NSMutableArray new];
    NSMutableArray * historyFriends = [NSMutableArray new];
    KWeakSelf;
    NSMutableArray * historyNewFriendsList = (NSMutableArray *)[self getPlistDictionary];
    NSLog(@"----------------%@",[self getPlistDictionary]);
    for (NSDictionary * historyDic in historyNewFriendsList) {
        NewFriendModel * historyFrModel = [NewFriendModel mj_objectWithKeyValues:historyDic];

        [historyFriends addObject:historyFrModel];

    }
    //取出好友申请消息 *******************************************
    /*  好友申请通过数据   cell里setModel写好了
     */
    NSArray * friendsDataAry = [[SystemDataBase shareSystemDataBase] queryFriendsNoticeMessages];
    if (friendsDataAry.count != 0) {
        NewFriendModel * historyFrModel = [NewFriendModel new];
        for (BTMessageModel * msgModel in friendsDataAry) {
            historyFrModel.head = msgModel.head;
            historyFrModel.isAgree = @"1";
            historyFrModel.nickname = msgModel.nickname;
            historyFrModel.applyContent = msgModel.msg;
            historyFrModel.isLocal = @"1";//标记为本地记录
            historyFrModel.fuuid = msgModel.fuuid;
            [historyFriends addObject:historyFrModel];

        }
    }

    [ContactRequestLogic requestNewFriendsListSuccess:^(NSDictionary * _Nonnull Dict) {
        NSDictionary * datadic =Dict[@"data"];
        NSArray * friend1sArray = datadic[@"friend1s"];
        NSArray * friend2sArray = weakSelf.addressBookFriends;
        //        NSMutableDictionary * dic =[NSMutableDictionary new];
        if (friend1sArray.count>0&&friend2sArray.count>0) {
            self.nullDataView.hidden=YES;
            for (NSDictionary * newDic in friend1sArray) {
                NewFriendModel * newFrModel = [NewFriendModel mj_objectWithKeyValues:newDic];
                
                [ValidationFriends addObject:newFrModel];
            }
            if (historyFriends.count>0) {
                [ValidationFriends enumerateObjectsUsingBlock:^(NewFriendModel * newModel, NSUInteger oldIdx, BOOL * _Nonnull stop) {
                    [historyFriends enumerateObjectsUsingBlock:^(NewFriendModel * historyModel, NSUInteger newIdx, BOOL * _Nonnull stop) {
                        
                        if ([historyModel.friendID isEqualToString:newModel.friendID]) {
                            [historyFriends removeObjectAtIndex:oldIdx];
                            [historyNewFriendsList removeObjectAtIndex:oldIdx];
                        }
                        
                    }];
                    
                }];
                [ValidationFriends addObjectsFromArray:historyFriends];
                
            }
            
            NSString *savepath =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
            NSLog(@"沙盒地址===%@", savepath);
            
            //拼接文件路径
            NSString *filePathName = [savepath stringByAppendingPathComponent:[NSString stringWithFormat:@"historyNewFriendsList_%@.plist",UserFuuid]];
            //想要把这个字典存储为plist文件.
            //直接把字典写入到沙盒当中
            //用字典写, plist文件当中保存的是字典.
            NSMutableArray * dataArr = [NSMutableArray new];
            
            NSArray *result;
            if (historyNewFriendsList.count != 0 ) {
                [historyNewFriendsList enumerateObjectsUsingBlock:^(NSDictionary * historyDic, NSUInteger oldIdx, BOOL * _Nonnull stop) {
                    [friend1sArray enumerateObjectsUsingBlock:^(NSDictionary * newDic, NSUInteger newIdx, BOOL * _Nonnull stop) {
                        if ([historyDic[@"id"] isEqualToNumber:newDic[@"id"]]) {
                            [historyNewFriendsList removeObjectAtIndex:oldIdx];
                        }
                        
                    }];
                }];
                [dataArr addObjectsFromArray:friend1sArray];
                [dataArr addObjectsFromArray:historyNewFriendsList];
                
            }else{
                [dataArr addObjectsFromArray:friend1sArray];
            }
            result = (NSArray *)dataArr;
            //获取沙盒路径
            //ToFile:要写入的沙盒路径
            [result writeToFile:filePathName atomically:YES];
            
            for (NSDictionary * localDic in friend2sArray) {
                NewFriendModel * localModel = [NewFriendModel mj_objectWithKeyValues:localDic];
                [localFriends addObject:localModel];
            }
            
            self.searchResultsArray=[NSMutableArray arrayWithObjects:ValidationFriends,localFriends, nil];
            
        }else if (friend1sArray.count>0&&friend2sArray.count==0){
            
            self.nullDataView.hidden=YES;
            weakSelf.newsType = @"0";//验证消息
            for (NSDictionary * newDic in friend1sArray) {
                NewFriendModel * newFrModel = [NewFriendModel mj_objectWithKeyValues:newDic];
                
                [ValidationFriends addObject:newFrModel];
                
            }
            if (historyFriends.count>0) {
                [ValidationFriends enumerateObjectsUsingBlock:^(NewFriendModel * newModel, NSUInteger oldIdx, BOOL * _Nonnull stop) {
                    [historyFriends enumerateObjectsUsingBlock:^(NewFriendModel * historyModel, NSUInteger newIdx, BOOL * _Nonnull stop) {
                        
                        if ([historyModel.friendID isEqualToString:newModel.friendID]) {
                            [historyFriends removeObjectAtIndex:oldIdx];
                            [historyNewFriendsList removeObjectAtIndex:oldIdx];
                        }
                        
                    }];
                    
                }];
                [ValidationFriends addObjectsFromArray:historyFriends];
                
            }
            
            NSString *savepath =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
            NSLog(@"沙盒地址===%@", savepath);
            
            //拼接文件路径
            NSString *filePathName = [savepath stringByAppendingPathComponent:[NSString stringWithFormat:@"historyNewFriendsList_%@.plist",UserFuuid]];
            //想要把这个字典存储为plist文件.
            //直接把字典写入到沙盒当中
            //用字典写, plist文件当中保存的是字典.
            NSMutableArray * dataArr = [NSMutableArray new];
            
            NSArray *result;
            if (historyNewFriendsList.count != 0 ) {
                [historyNewFriendsList enumerateObjectsUsingBlock:^(NSDictionary * historyDic, NSUInteger oldIdx, BOOL * _Nonnull stop) {
                    [friend1sArray enumerateObjectsUsingBlock:^(NSDictionary * newDic, NSUInteger newIdx, BOOL * _Nonnull stop) {
                        if ([historyDic[@"id"] isEqualToNumber:newDic[@"id"]]) {
                            [historyNewFriendsList removeObjectAtIndex:oldIdx];
                        }
                        
                    }];
                }];
                [dataArr addObjectsFromArray:friend1sArray];
                [dataArr addObjectsFromArray:historyNewFriendsList];
                
            }else{
                [dataArr addObjectsFromArray:friend1sArray];
            }
            result = (NSArray *)dataArr;
            //获取沙盒路径
            //ToFile:要写入的沙盒路径
            [result writeToFile:filePathName atomically:YES];
            
            
            self.searchResultsArray=[NSMutableArray arrayWithObjects:ValidationFriends, nil];
            
            
        }else if (friend1sArray.count==0&&friend2sArray.count>0){
            self.nullDataView.hidden=YES;
            for (NSDictionary * localDic in friend2sArray) {
                NewFriendModel * localModel = [NewFriendModel mj_objectWithKeyValues:localDic];
                [localFriends addObject:localModel];
            }
            weakSelf.newsType = @"1";
            self.searchResultsArray=[NSMutableArray arrayWithObjects:localFriends, nil];
            
        }else if (friend1sArray.count==0&&friend2sArray.count==0)
        {
            if (historyFriends.count == 0) {
                self.nullDataView.hidden=NO;
            }else{
                weakSelf.newsType = @"0";
                NSSet *set = [NSSet setWithArray:historyFriends];
                NSArray * newAry = [set allObjects];
                self.searchResultsArray = [NSMutableArray arrayWithObjects:newAry, nil];
            }
            
            
        }
        
        [self.friendsTable reloadData];
        AAIMLog(@"列表数据=%@",Dict);
        
    } failure:^(NSString * _Nonnull errMsg) {
        
        [self showTipHudWithText:errMsg];
    }];
    
}
-(NSString *)convertToJsonData:(NSArray *)ary

{
    
    NSError *error;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ary options:NSJSONWritingPrettyPrinted error:&error];
    
    NSString *jsonString;
    
    if (!jsonData) {
        
        NSLog(@"%@",error);
        
    }else{
        
        jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
        
    }
    
    NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
    
    NSRange range = {0,jsonString.length};
    
    //去掉字符串中的空格
    
    [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
    
    NSRange range2 = {0,mutStr.length};
    
    //去掉字符串中的换行符
    
    [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
    
    return mutStr;
    
}

//读取plist（代码创建的plist文件）

- (NSArray *)getPlistDictionary

{
    NSString *savepath =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
    NSLog(@"沙盒地址===%@", savepath);
    
    //拼接文件路径
    NSString *filePathName = [savepath stringByAppendingPathComponent:[NSString stringWithFormat:@"historyNewFriendsList_%@.plist",UserFuuid]];
    NSArray *dataArray = [NSArray arrayWithContentsOfFile:filePathName];
    
    //    NSArray * newFriendsHistoryAry=[CacheTool readPlist:[NSString stringWithFormat:@"historyNewFriendsList_%@.plist",UserFuuid] dataClass:NSMutableDictionary.class];
    
    return dataArray;
}


-(void)setui
{
    _friendsTable=[[UITableView alloc]initWithFrame:CGRectMake(0, NavigationBarHeight, SCREEN_WIDTH,SCREEN_HEIGHT-NavigationBarHeight) style:UITableViewStyleGrouped];
    _friendsTable.delegate=self;
    _friendsTable.dataSource=self;
    _friendsTable.rowHeight=60;
    _friendsTable.showsVerticalScrollIndicator = NO;
    _friendsTable.backgroundColor=[UIColor whiteColor];
    [_friendsTable registerClass:[FirendsTableViewCell class] forCellReuseIdentifier:@"newFirendCell"];
    _friendsTable.separatorStyle=UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.friendsTable];
    [self.friendsTable addSubview:self.nullDataView];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = KHEXCOLOR(kGrayColor_f2);
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 7.5, tableView.frame.size.width - 20, 15)];
    label.backgroundColor =  [UIColor clearColor];
    label.font = [UIFont systemFontOfSize:12];
    label.textAlignment=0;
    label.textColor=KHEXCOLOR(@"#BBBBBB");
    NSString *title ;
    if (self.searchResultsArray.count == 1 && [_newsType isEqualToString:@"0"]) {
         title = @"验证消息";
    }else if(self.searchResultsArray.count == 1 && [_newsType isEqualToString:@"1"]){
       title = @"通讯录好友";
    }else{
       if (section==0) {
              title = @"验证消息";
          }else {
              title = @"通讯录好友";
          }
    }
  
    label.text = [NSString stringWithFormat:@"%@", title];
    [view addSubview:label];
    return view;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"同意或者拒绝好友申请");
    NewFriendModel * friendModel = _searchResultsArray[indexPath.section][indexPath.row];
    if ([friendModel.isAgree isEqualToString:@"1"]) {
        FriendsInfoViewController * vc=[[FriendsInfoViewController alloc]init];
                   vc.isFriend = [friendModel.isAgree integerValue];
                   vc.Fuuid = friendModel.fuuid;
                   vc.type = @"search";
                   [self.navigationController pushViewController:vc animated:YES];
    }else{
    if (indexPath.section==0) {
        FriendRequestsViewController * vc=[[FriendRequestsViewController alloc]init];
        vc.model = friendModel;
        [self.navigationController pushViewController:vc animated:YES];
    }
    }
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.searchResultsArray.count;
    //    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.searchResultsArray[section]count];
    //    return 1;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    FirendsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"newFirendCell"];
    NewFriendModel * model = _searchResultsArray[indexPath.section][indexPath.row];
    cell.friendModel = model;
    cell.delegate=self;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
}

#pragma mark -friendCellDelegate
-(void)FirendsTableViewCellWithClickSelecdCell:(FirendsTableViewCell *)cell
{
    NSString * btnTitle = cell.invitationBtn.titleLabel.text;
    if ([btnTitle isEqualToString:@"接受"]) {
        NSIndexPath * index = [_friendsTable indexPathForCell:cell];
           NewFriendModel * models = _searchResultsArray[index.section][index.row];
           
           [ContactRequestLogic requestAgreedFriendWithID:models.fuuid isAgree:@"1" Success:^(NSDictionary * _Nonnull Dict) {
               NSLog(@"同意申请：%@",Dict);
               NSLog(@"同意好友，更新本地好友数据，发送im告知对方");
               [[UserDataBaseTool shareUserDataBaseTool] reloadData:1 Success:^(BOOL isOK) {
                   if (isOK) {
                       if (self.friendVCBlock) {
                           self.friendVCBlock(@"refreshFriendList");
                       }
                   }
               }];
               
               [self showTipHudWithText:Dict[@"message"]];
               
               [CommonTools changeNewFriendsStatus:1 withFriendID:models.friendID];
               [self loadData];
               
               // 存储数据库
               BTMessageModel *textModel = [BTMessageModel new];
               textModel.msgtype = MessageTypeText;
               textModel.messageDirection = MessageDirectionSend;
               textModel.fuuid = [LoginManager shareLoginManager].userModel.fuuid;
               textModel.f_uuid = [LoginManager shareLoginManager].userModel.fuuid;
               long long timestamp =  [ChatTool shareChatTool].currentTimestamp;
               textModel.timestamp = timestamp;
               textModel.head = [LoginManager shareLoginManager].userModel.head;
               textModel.username = [LoginManager shareLoginManager].userModel.nickname;
               textModel.rfuuid =  models.fuuid;
               textModel.chatType = ChatTypeFriend;
               textModel.gId = models.fuuid;
               textModel.addfriendState = 1;
               textModel.nickname = [LoginManager shareLoginManager].userModel.nickname;
//               textModel.messageStatus = MessageStatusDelivering;
               textModel.type_id=SystemMessageAgreeAddFriend;
               [[ConversationListDataBase shareConversationListDataBase] saveConversation:textModel];
               [[ConversationManager shareManager] saveConversation:textModel];
               
           } failure:^(NSString * _Nonnull errMsg) {
               if ([errMsg isEqualToString:@"已是好友"]) {
                   [self loadData];
               }
               [self showTipHudWithText:errMsg];
           }];
    }else{

          _sendAddFriendAlert=[[CustomAlertView alloc]initWithFrame:self.view.bounds withType:@"8" title:[LoginManager shareLoginManager].userModel.userName];
        KWeakSelf;
            _sendAddFriendAlert.clickBlock = ^(NSString * _Nonnull selectType, NSString * _Nonnull textf, NSString * _Nonnull remarkStr) {
                NSIndexPath * index = [weakSelf.friendsTable indexPathForCell:cell];
                   NewFriendModel * models = weakSelf.searchResultsArray[index.section][index.row];
                if ([selectType isEqualToString:@"2"]) {

                    [ContactRequestLogic  requestAddFriendWithContent:textf fuuid:models.fuuid groupid:@"" source:@"s" Success:^(NSDictionary * _Nonnull Dict) {
                        [weakSelf showTipHudWithText:Dict[@"message"]];
                        //申请成功发送im消息
                        NSLog(@"发送请求%@",Dict);
                        
                        
                    } failure:^(NSString * _Nonnull errMsg) {
                        [weakSelf showTipHudWithText:errMsg];
                    }];
                }
                [weakSelf.sendAddFriendAlert removeFromSuperview];
            };
            [[UIApplication sharedApplication].keyWindow addSubview:_sendAddFriendAlert];
        }
}
-(MJTableViewNullDataView*)nullDataView
{
    if (!_nullDataView) {
        _nullDataView=[[MJTableViewNullDataView alloc]initWithFrame:CGRectMake(0,0*SCALAE, _friendsTable.frame.size.width, _friendsTable.frame.size.height)];
        _nullDataView.hidden=YES;
        _nullDataView.backgroundColor=[UIColor whiteColor];
    }
    [_nullDataView setCustomViewFrame:@"空状态" message:@"暂时没有数据噢~"];
    return _nullDataView;
}
-(NSMutableArray*)searchResultsArray
{
    if (!_searchResultsArray) {
        _searchResultsArray=[[NSMutableArray alloc]init];
    }
    return _searchResultsArray;
}

//
//- (void)saveLocalData:(NewFriendModel *)newModel{
//    NSString *savepath =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
//    NSLog(@"沙盒地址===%@", savepath);
//
//    //拼接文件路径
//    NSString *filePathName = [savepath stringByAppendingPathComponent:[NSString stringWithFormat:@"historyNewFriendsList_%@.plist",UserFuuid]];
//    //想要把这个字典存储为plist文件.
//    //直接把字典写入到沙盒当中
//    //用字典写, plist文件当中保存的是字典.
//    NSMutableArray * dataArr = [NSMutableArray new];
//  NSDictionary * dic = [self dicFromObject:newModel];
//    [dataArr addObject:dic];
//    NSArray *result = (NSArray *)dataArr;
//    //获取沙盒路径
//    //ToFile:要写入的沙盒路径
//    [result writeToFile:filePathName atomically:YES];
//}
//
////model转化为字典
//- (NSDictionary *)dicFromObject:(NSObject *)object {
//    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
//    unsigned int count;
//    objc_property_t *propertyList = class_copyPropertyList([object class], &count);
//
//    for (int i = 0; i < count; i++) {
//        objc_property_t property = propertyList[i];
//        const char *cName = property_getName(property);
//        NSString *name = [NSString stringWithUTF8String:cName];
//        NSObject *value = [object valueForKey:name];//valueForKey返回的数字和字符串都是对象
//
//        if ([value isKindOfClass:[NSString class]] || [value isKindOfClass:[NSNumber class]]) {
//            //string , bool, int ,NSinteger
//            [dic setObject:value forKey:name];
//
//        } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) {
//            //字典或字典
//            [dic setObject:[self arrayOrDicWithObject:(NSArray*)value] forKey:name];
//
//        } else if (value == nil) {
//            //null
//            //[dic setObject:[NSNull null] forKey:name];//这行可以注释掉?????
//
//        } else {
//            //model
//            [dic setObject:[self dicFromObject:value] forKey:name];
//        }
//    }
//
//    return [dic copy];
//}
//
////将可能存在model数组转化为普通数组
//- (id)arrayOrDicWithObject:(id)origin {
//
//    if ([origin isKindOfClass:[NSArray class]]) {
//        //数组
//        NSMutableArray *array = [NSMutableArray array];
//        for (NSObject *object in origin) {
//            if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]]) {
//                //string , bool, int ,NSinteger
//                [array addObject:object];
//
//            } else if ([object isKindOfClass:[NSArray class]] || [object isKindOfClass:[NSDictionary class]]) {
//                //数组或字典
//                [array addObject:[self arrayOrDicWithObject:(NSArray *)object]];
//
//            } else {
//                //model
//                [array addObject:[self dicFromObject:object]];
//            }
//        }
//
//        return [array copy];
//
//    } else if ([origin isKindOfClass:[NSDictionary class]]) {
//        //字典
//        NSDictionary *originDic = (NSDictionary *)origin;
//        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
//        for (NSString *key in originDic.allKeys) {
//            id object = [originDic objectForKey:key];
//
//            if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]]) {
//                //string , bool, int ,NSinteger
//                [dic setObject:object forKey:key];
//
//            } else if ([object isKindOfClass:[NSArray class]] || [object isKindOfClass:[NSDictionary class]]) {
//                //数组或字典
//                [dic setObject:[self arrayOrDicWithObject:object] forKey:key];
//
//            } else {
//                //model
//                [dic setObject:[self dicFromObject:object] forKey:key];
//            }
//        }
//
//        return [dic copy];
//    }
//
//    return [NSNull null];
//
//}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
